package biz.ws.ws;

import api.common.util.CommonUtils;

import java.util.HashSet;
import java.util.Set;

/**
 * @创建人 xiaojiancheng
 * @时间 2020/10/7
 * @描述 $
 */
public class WsCst {
    public static class MsgType{
        /**
         *  消息的类型
         *  {@link #SEND_USER}          用户主动发送 需要发送给其他的用户
         *  {@link #BEAT}               心跳
         *  {@link #SEND_REPLY}         用户收到消息之后 发送这个信号 表示已经收到消息了
         *  {@link #RECEIVE_CONSOLE}    日志中心的数据 这里发送给指定的用户
         */
        public static final String SEND_USER = "send_user";
        public static final String SEND_REPLY = "send_reply";
        public static final String BEAT = "beat";
        public static final String RECEIVE_CONSOLE = "receive_console";

        private static Set<String> keySet = new HashSet<>();

        static {
            CommonUtils.loadStringConstByClass(MsgType.class,keySet);
        }

        public static boolean check(String type){
            return keySet.contains(type);
        }
    }

    public static class MsgStatus {
        /**
         *  消息的状态
         *  {@link #NOT_SEND}       没有发送
         *  {@link #SEND}           已经发送
         *  {@link #SEND_FAILURE}   发送失败
         */
        public static final String NOT_SEND = "not_send";
        public static final String SEND = "send";
        public static final String SEND_FAILURE = "send_failure";
    }

    public static class TopicName {
        public static final String WS_SEND = "ws_send";
    }

    public static class MsgSource {
        /**
         *  消息来源
         */
        public static final String CLIENT = "client";
        public static final String KAFKA_MAIN = "kafka_main";
        public static final String KAFKA_TEMP = "kafka_temp";
    }

    public static class LoginType {
        /**
         *  {@link #PASSWORD}       username/password   的登录方式
         *  {@link #TOKEN}          token 的登录方式
         *  {@link #DIRECT}         直接链接 没有任何校验 (测试的时候可以使用)
         */
        public static final String PASSWORD = "password";
        public static final String TOKEN = "token";
        public static final String DIRECT = "direct";
    }
}
